using System;
using System.Web.UI.WebControls;
using eWorld.UI;

namespace TimeSheet.Protected.View.Model
{
    /// <summary>
    ///		Summary description for EditActivity.
    /// </summary>
    public abstract class EditActivity : EntityControl
    {
        protected Button btnSave;
        protected Label lblAddEditTitle;
        protected ValidationSummary ValidationSummary1;
        protected TextBox ActivityName;
        protected TextBox Description;
        protected RequiredFieldValidator RequiredFieldValidator1;
        protected CheckBox Active;
        protected CollapsablePanel cpEntity;

        private void Page_Load(object sender, EventArgs e)
        {
            BindControlToEntity();
            if (BoundEntity.ID > 0)
            {
                btnSave.Text = "Update";
                lblAddEditTitle.Text = "Edit Activity";
            }
            else
            {
                btnSave.Text = "Create";
                lblAddEditTitle.Text = "Add Activity";
            }
        }

        #region Web Form Designer generated code

        protected override void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
        }

        ///		Required method for Designer support - do not modify
        ///		the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
            this.Load += new System.EventHandler(this.Page_Load);
        }

        #endregion

        private void btnSave_Click(object sender, EventArgs e)
        {
            LoadEntityFromForm();
            SaveBoundEntity();
            Response.Redirect("~/Protected/Activity.aspx");
        }
    }
}